﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/ViewMasterPage1.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<ComputerShopE3.Models.SAN_PHAM>>" %>
<%@ Import Namespace="ComputerShopE3.Models" %>
<%@ Import Namespace="MyHelper" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Danh sách sản phẩm</h2>

    <table>
        <tr>
            <th></th>
            <%--<th>
                id
            </th>--%>
            <th>
                HinhAnh
            </th>
            <th>
                TenSanPham
            </th>
            <th>
                NhaSanXuat
            </th>
            <td>
                NhaPhanPhoi
            </td>
            <th>
                MoTa
            </th>
            <th>
                Gia
            </th>
            <th>
                idKhuyenMai
            </th>
            <th>
                Diem
            </th>
            <%--<th>
                SoLuongTon
            </th>--%>
            <%--<th>
                NgayThemSP
            </th>--%>
            <%--<th>
                BaoHanh
            </th>--%>
            <th>
                LoaiSanPham
            </th>
            <%--<th>
                LaLinhKien
            </th>--%>
            <%--<th>
                MauSac
            </th>--%>
        </tr>

    <% foreach (var item in Model)
       { %>
    
        <tr>
            <td>
                <%= Html.ActionLink("Edit", "Edit", new { id=item.id }) %> |
                <%= Html.ActionLink("Details", "Details", new { id=item.id })%>
            </td>
            <td>
                <% foreach (var ha in item.HINH_ANH)
                   { %>
                <%= Html.ImageActionLink("../../content/data_images/" + ha.Url, "details", item.LOAI_SAN_PHAM.TenLoaiSanPham, new { id = item.id }, null, null)%>
                <%} %>
                
            </td>
            <%--<td>
                <%= Html.Encode(item.id) %>
            </td>--%>
            <td>
                <%= Html.Encode(item.TenSanPham) %>
            </td>
            <td>
                <% if (item.NHA_SAN_XUAT != null)
                   { %>
                <%= Html.Encode(item.NHA_SAN_XUAT.TenNSX)%>
                <%} %>
            </td>
            <td>
                <% if (item.NHA_PHAN_PHOI != null)
                   { %>
                <%= Html.Encode(item.NHA_PHAN_PHOI.TenNhaPhanPhoi)%>
                <% } %>
            </td>
            <td>
                <%= Html.Encode(item.MoTa) %>
            </td>
            <td>
                <%= Html.Encode(item.Gia) %>
            </td>
            <td>
                <%= Html.Encode(item.idKhuyenMai) %>
            </td>
            <td>
                <% var Diem = (item.Diem > 5) ? 5 : item.Diem; %>
                <% for (int i = 0; i < Diem; i++) { %>
                <img src="../../Content/images/choice.png" />
                <% } 
                    Diem = 5 - Diem;
                    for (int i = 0; i < Diem; i++) { %>
                <img src="../../Content/images/nochoice.png"/>
                <% } %>
            </td>
            <%--<td>
                <%= Html.Encode(item.sp.SoLuongTon) %>
            </td>
            <td>
                <%= Html.Encode(String.Format("{0:g}", item.sp.NgayThemSP)) %>
            </td>--%>
           <%-- <td>
                <%= Html.Encode(item.BaoHanh) %>
            </td>--%>
            <td>
                <%= Html.Encode(item.LOAI_SAN_PHAM.TenLoaiSanPham) %>
            </td>
           <%-- <td>
                <%= Html.Encode(item.LaLinhKien) %>
            </td>--%>
            <%--<td>
                <%= Html.Encode(item.MauSac) %>
            </td>--%>
        </tr>
    
    <% } %>

    </table>

    <p>
        <%= Html.ActionLink("Create New", "Create") %>
    </p>

</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
    <title>Sản phẩm</title>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="PersonalMenu" runat="server">
</asp:Content>

